#include "MethodRaw.h"

using namespace FitMethods;

FitResult MethodRaw::runAnalysisCase(AnalysisConfig config, FitInput input) {
    RooRealVar & nSignal = *new RooRealVar("nSignal", "amount of signal events", 0, 0, 1000000000);
    gc->add(&nSignal);
    Utility::calculateIntegral(nSignal,input.getData(),config.getIsolThr(),true);
    vector <RooRealVar *> signalVector;
    signalVector.push_back(&nSignal);
    /// WARNING: this should be solved some other way than creating a new variable just to return it
    RooRealVar * isol = new RooRealVar("isol","E_{T}^{cone40}/E_{T}",-0.2,1.5);
    gc->add(isol);
    RooDataHist * rooDataHist = new RooDataHist("rooDataHist", "Isolation", *isol, input.getData());
    gc->add(rooDataHist);
    FitResult res("MethodRaw",signalVector,vector <RooRealVar *>());
    vector <RooRealVar *> nBgdIsolThVector, nSigIsolThVector;
    /// WARNING: multiple background vectors ignored for nBgdIsolTh
    RooRealVar & nBackground = *new RooRealVar("nBackground", "amount of background events", 0, 0, 1000000000);
    gc->add(&nBackground);
    nBgdIsolThVector.push_back(&nBackground);
    nSigIsolThVector.push_back(&nSignal);
    res.setBgdBelowIsolTh(nBgdIsolThVector);
    res.setSigBelowIsolTh(nSigIsolThVector);
    return res;
}
